<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<style type="text/css">
		table{
			border-collapse: collapse;
		}
	</style>
	    
	<body>
	   <form>
	    <table id="myTab" width="300px" height="30px" border="1">
	    	<tr>
	    		<td height="30px"></td>
	    		<td></td>
	    		<td></td>
	    		<td></td>
	    	</tr>
	    </table>
	        <input type="button" value="添加一行" onclick="add()" />
	        <input type="button" value="删除最后行" onclick="del()" />
	    </form>
	    <script>
	     function add(){
	    	var table=document.getElementById("myTab");
	    	var tr=document.createElement("tr");
	    	for(var i=1;i<5;i++){
	    		var td=document.createElement("td");
	    		td.style.height="30px";
	    		tr.appendChild(td);
	    	}
	    	table.appendChild(tr);
	    }
	    
	    function del(){
	    	var table=document.getElementById("myTab");
	    	var tr=table.lastChild;
	    	var td=tr.childNodes;
	    	if(table.rows.length==1){
	    		alert("最后一行不可删除! ");
	    	}
	    	else{
	    		table.removeChild(tr);
	    	}
	    }
	    </script>
	    
	</body>
</html>
